<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel="shortcut icon" href="#" type="image/x-icon">

  <style>
    .box {
      width: 500px;
      height: 88px;
      background-color: lightblue;
    }
  </style>
</head>

<body>

  <input type="text" class="text">
  <input type="password" name="" id="" class="text2">
  <button class="btn2">走你~</button>
  <div class="box">
    查询结果如下：
  </div>

  <script>
    let box = document.getElementsByClassName('box')[0];
    let btn2 = document.getElementsByClassName('btn2')[0];



    btn2.onclick = function () {
      let text = document.getElementsByClassName('text')[0].value;
      let pwd = document.getElementsByClassName('text2')[0].value;
      console.log('btn2')
      const xhr = new XMLHttpRequest();
      xhr.open('GET', `http://127.0.0.1:8888/chuancan?username=${text}&pwd=${pwd}`, true);
      xhr.send();
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status >= 200 && xhr.status < 300) {
            box.innerHTML = xhr.response;
          }
        }
      }
    }
  </script>
</body>

</html>